<?php

$serv = slt_silent_init('0.0.0.0', 8079, TCP_MODE);
slt_silent_set($serv, ['backend'=>0, 'agent_num'=>6, 'job_num'=>4]);
slt_silent_handler($serv, ['on_conn'=>function($ip, $schedid) {

}]);

slt_silent_handler($serv, ['on_rcv'=>function($schedid, $data, $len) {
	$ret = 'rcv: ' . substr($data, 0, rand(0, strlen($data))) . PHP_EOL;
	echo $ret, PHP_EOL;
	
	return $data;
}]);

slt_silent_handler($serv, ['on_done'=>function($data, $len) {
	echo $data, PHP_EOL;
	return $data;
}]);

slt_silent_task($serv, 1, function() {
	echo time(), PHP_EOL;
});
slt_silent_task($serv, 3, function() {
    echo time(), PHP_EOL;
});
slt_silent_task($serv, 4, function() {
    for ($i=0; $i<100; $i++) {
		echo time(), PHP_EOL;
	}
});
slt_silent_task_one($serv, 5, function() {
	echo http_build_query(['aa'=>22222, 'bcc'=>4444, 'ccccc'=>['sssdfdfsf', 'sdddd'=>time()]]), PHP_EOL;
});
slt_silent_run($serv);
